Identifiers
An identifier is a series of characters that identifies a value or other language element. For example, variable names are identifiers. In the following statement, the variable namemyName
identifies the value"Fred"
.
set myName to "Fred"Identifiers are also used as labels for properties and handlers. You'll learn about these uses later in this guide.An identifier must begin with a letter and can contain uppercase letters, lowercase letters, numerals (0-9), and the underscore character (_). Here
are some examples of valid identifiers:
Yes Agent99 Just_Do_ItThe following are not valid identifiers:
C-- Back&Forth 999 Why^NotIdentifiers whose first and last characters are vertical bars (|
) can contain any characters. For example, the following are legal identifiers:
|Back and Forth| |Right*Now!|Identifiers whose first and last characters are vertical bars can contain additional vertical bars if the vertical bars are preceded by backslash (\) characters, as in the identifier|This\|Or\|That|
. A backslash character in an identifier must be preceded by a backslash character, as in the identifier|/\\ Up \\/ Down
|.AppleScript identifiers are not case sensitive. For example, the variable identifiers
myvariable
andMyVariable
are equivalent.Identifiers cannot be the same as any reserved words--that is, words in the system dictionary or words in the dictionary of the application named in the Tell statement. For example, you cannot create a variable whose identifier is
Yes
within a Tell statement to the Scriptable Text Editor, becauseYes
is a constant from the Scriptable Text Editor dictionary. In this case, AppleScript returns a syntax error if you useYes
as a variable identifier.